<%-- 
    Document   : ThiSinhTraCuuKetQuaThi
    Created on : Mar 29, 2012, 11:51:20 AM
    Author     : ducquyen
--%>

<%@page import="Pojo.Ketqua"%>
<%@page import="java.util.List"%>
<%@page import="java.util.List"%>
<%@taglib  uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<script lang="javascript">
    <%
        if(Integer.parseInt(request.getAttribute("dangnhapthatbai").toString()) == 0)
    {%>
        Print_False();
    <%}%>
    function Print_False()
    {
        alert("CMND này chưa tồn tại!\n\nMời bạn nhập lại")
        return;
    }
    function KiemTra(){
        var frm = document.getElementById("frmTraCuuKetQuaThi");
        var cm = frm.cmnd.value;
        var loi = "";
        if(cm==""){
            loi+="Vui lòng nhập CMND !";
        }
            
        if(KiemTraKyTu(cm)==false){
            loi+="CMND phải là số !"
        }
        return loi;
        
    }
    
    function KiemTraKyTu(kt)
    {
        return ! isNaN (kt-0);
    }
    function TraCuuKetQuaThi_Click(){
        var frm = document.getElementById("frmTraCuuKetQuaThi");
        if(KiemTra()==""){
            
            frm.submit();
        }
        else{
            alert(KiemTra());
        }
    }
</script>

<div id="idcustomer1">
    <%
        if(session.getAttribute("username_") == null){
    %>
        <form name="frmTraCuuKetQuaThi" method="post" action="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu" id="frmTraCuuKetQuaThi">

            <div id="title_thongtin"><b id="thongtinthisinh">Nhập thông tin thí sinh</b></div>
            <div style="height: 100px"></div>
            <div id="nhapthongtin">
                <div style="height: 15px"></div>

                <div style="height: 15px"></div>
                <div>
                    <b id="noidung">Nhập CMND:</b>
                    <input style="margin-left: 41px;height: 20px;width: 180px" type="text" name="CMND" value="" id="cmnd"/>

                </div>
                <div style="height: 15px"></div>
                <div style="text-align: center" ><input type="button" value=" Tra Cứu " id="btnTraCuu" name="btnTraCuu" onclick="TraCuuKetQuaThi_Click()"/> </div>
            </div>
        </form>

        <div style="height: 250px"></div>
    <%}else{%>

    <%

        if (session.getAttribute("ThiSinhTraCuuKetQuaThi_ketQuaTraCuu") != null) {
            List<Ketqua> arrkq = (List<Ketqua>) session.getAttribute("ThiSinhTraCuuKetQuaThi_ketQuaTraCuu");
            if (arrkq.size() > 0) {%>
    <div id="title_thongtin"><b id="customizecauhoi">Kết quả tra cứu</b></div>

    <div style="height: 20px"></div>


    <div style="height: 15px"></div>
    <div id="cauhoi">
        <div style="height: 15px"></div>
        <div style="margin-left: 10px;margin-right: 10px">
            <table style="width: 100% " border="1">
                <tr>
                    <td style="width: 25% ;text-align: center ">Họ tên</td>
                    <td style="width: 15% ;text-align: center">CMND</td>
                    <td style="width: 10% ;text-align: center ">Đề thi</td>
                    <td style="width: 20% ;text-align: center ">Thời Gian Bắt Đầu</td>
                    <td style="width: 20% ;text-align: center ">Thời Gian Kết Thúc</td>
                    <td style="width: 10% ;text-align: center ">Điểm</td>                    
                </tr><%
                    for (int i = 0; i < arrkq.size(); i++) {
                        Ketqua kq = arrkq.get(i);
                %>
                <tr>
                    <td style="width: 25% ;text-align: center "><b style="font-weight: bold"><%= kq.getThisinh().getHoTen()%></b></td>
                    <td style="width: 15% ;text-align: center"><%= kq.getThisinh().getCmnd()%></td>

                    <td style="width: 10% ;text-align: center "><a href="Tracuuketquadathi?madethi=<%= kq.getDethi().getMaDeThi()%>&maketqua=<%=kq.getMaKetQua()%>&maThiSinh=<%=kq.getThisinh().getMaThiSinh()%>"> <%= kq.getDethi().getMaDeThi()%></a></td>
                    <td style="width: 20% ;text-align: center "><%= kq.getThoiGianBatDau()%></td>
                    <td style="width: 20% ;text-align: center "><%= kq.getThoiGianKetThuc()%></td>
                    <td style="width: 10% ;text-align: center "><%= kq.getDiem()%></td>                    
                </tr>
                <%          }
                %>

            </table>
            <div style="height: 25px"></div>

        </div>
        <div style="margin-left: 10px;margin-right: 10px ; text-align: center">Trang : 

            <%
                if (request.getParameter("Trang") != null && request.getParameter("TongSoTrang") != null) {
                    int soLuongTrang = Integer.parseInt(request.getParameter("TongSoTrang"));
                    int trang = Integer.parseInt(request.getParameter("Trang"));
                    if (trang > 1) {%>
                        <a href="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu&Trang=<%=1%>">[Đầu]</a>
                        <a href="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu&Trang=<%=trang - 1%>">[Trước]</a>
                    <%  }
                for (int i = 1; i <= soLuongTrang; i++) {%>
                    <a href="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu&Trang=<%=i%>" style="<%if (trang == i) {
                    out.print("font-size: large ;font-weight: bold");
                    }%>" > <%=i%> </a>

                <%}
                if (trang < soLuongTrang) {%>
                    <a href="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu&Trang=<%=trang + 1%>">[Sau]</a>
                    <a href="ThiSinhTraCuuKetQuaThicontroller?Action=TraCuu&Trang=<%=soLuongTrang%>">[Cuối]</a>
                <%}%>
            </div>
            <div style="height: 200px"></div>
            <%}
                }else{%>
        <div id="title_thongtin"><b id="customizecauhoi">Không tìm được kết quả nào !</b></div>

        <div style="height: 20px"></div><%
                }
            }
        %>
    </div>
    <div style="height: 4px"></div>
    <%}%>
</div>


